﻿using Abp.Domain.Repositories;
using Abp.Domain.Services;
using System;

using System.Linq.Expressions;

namespace AVIS.OutBound.OrderPay
{

    public class OrderPayLogManager : DomainService, IOrderPayLogManager{

        private readonly IRepository<OrderPayLog> _repository;

        public OrderPayLogManager(IRepository<OrderPayLog> repository){
            _repository = repository;
        }

        public OrderPayLog GetOrderPayLog(int AvisOBOrderId){
            Expression<Func<OrderPayLog, bool>> filter = c => c.AvisOBOrderId == AvisOBOrderId;
            var orderPayLog = _repository.FirstOrDefault(filter);
            return orderPayLog;
        }

        public void SavePayLog(OrderPayLog orderPayLog){
            if (orderPayLog == null){
                throw new Exception("保存失败!");
            }
            orderPayLog.CreateDate = Abp.Timing.Clock.Now;
            _repository.Insert(orderPayLog);
        }
    }
}
